import json
from khl import Bot, Message
from ai_core import ai_talk
from bot_api import send_message

with open("./ignore/config.json", "r") as f:
    config = json.load(f)

bot_token = config["bot_token"]

bot = Bot(token=bot_token)

@bot.on_message()
async def on_message(msg: Message):
    msg_id = send_message("Generating", msg.target_id)
    ai_talk(msg.content, msg_id)

    # print(msg.target_id)
    # print(f"收到消息: {msg.content} (来自用户: {msg.author.username})")

bot.run()
